current task.
So, if we want to not let the system kill our app, we can optimize it from the process level, memory consumption and so on.
ConclusionThis article plus gc those things, we talked about two of theoretical knowledge, I believe you have a general understanding of the memory management of Android, the following will introduce some memory analysis tools and use, the actual to explain how to analyze memory problems.Anly_junLinks
the message, and update the information in the activityWhat kinds of Android life cycle do you have?1. foreground process. Such a process has an activity that is displayed on the screen and interacts with the user or one of its intentreciver is running. Such programs are of the highest importance, and only when the system is very low in memory will it end up as a last resort. 2. visible process. Programs that are displayed on the screen but are not
resources in the application can be directly used, specific, you can go to the corresponding folder in ANDROID-SDK to see. For example: can enter the $android-sdk$\platforms\android-8\data\res, inside of system resources is sweeping.Developers need to spend some time familiarizing themselves with these resources, especially the picture resources and various styl
attention to the quality of the code, timely collection of bitmap objects, Can avoid the occurrence of outofmemory anomalies.If the picture of the program comes from outside, this time special need to pay attention to the occurrence of outofmemory. One is that if the loaded picture is larger, it needs to be narrowed first, and the other is to catch the exception and avoid the program crash.
Optimization Series related blog posts:Android Development Optimization--memory optimization f
be extracted.3) Bottom of the navigation bar. If the navigation bar is applied and most of the activity's bottom navigation bar is the same, the navigation bar can be written as a generic module.4) ListView. Most applications use the ListView to show multiple data. The ListView style may often be adjusted later in the project, so it is better to use the ListView as a common module.
Optimization Series related blog posts:Android Development Optimization--memory optimization for bitmap
to add, find, delete and so on, so, Scenario and Sparsearray, if the data volume is relatively large, then its performance will degrade at least 50%.Add datapublicputvalue)Get Datapublicget(Objectkey)Delete datapublic V remove(Objectkey)Unique methodsLike Sparsearray, it has two more convenient ways to get data:publickeyAt(int index)publicvalueAt(int index)Arraymap Application Scenarios
Small amount of data, preferably within thousand
Data structure type is map type
ArrayMapKe
This article introduces several tools for performance analysis on Android, all from the SDK, each strong enough for everyone to analyze and use.First, say TraceView.This tool in the SDK documentation is a bit more casual and probably says something about it. But the real need to use it to analyze the problem also requires a detailed understanding of how to use and quickly locate the problem.The following will be divided into four parts:The first is th
Recently released on GOOGL play apk to optimizeThe Android SDK includes a "zipalign" tool that optimizes packaged applications. Run Zipalign on your application to make the interaction between Android and the application more efficient at run time. As a result, this approach allows applications and the entire system to run faster. We strongly recommend using the Zipalign tool on new and published programs t
replaced by the loaded view, and the View object is returned. This allows the application to get a reference to the load view without additional execution of Findviewbyid ().
Experience Sharing:The viewstub can be associated with the layout resource file specified in the XML file, allowing the layout resource file to be loaded again when it is needed. When and when to load, without having to load at the start of the boot. Doing so can speed up application startup and save memory
="Android.intent.category.LAUNCHER" /> intent-filter>activity>This is not finished, because we SplashActivity set a background map for more, it is bound to cause the transition to draw, so we before its initialization. Set the theme back to the original:@Override protectedvoidonCreate(Bundle savedInstanceState) { setTheme(R.style.AppTheme); super.onCreate(savedInstanceState); setContentView(R.layout.splash_activity);Above.Now you will find that even if the boot tim
Some of the theoretical aspects of performance optimization, mainly to review, with the theory, Comrade Xiaoping said again, practice is the only standard to test the truth, for memory leaks, now through the Android Studio self-brought tool memory monitor detected. The importance of performance optimization does not need to be stressed, but to emphasize that I am not an old driver, hey! Please open your eyes if you have not used this tool. If you have
the number of the 2 index times, below I provide a calculation method:/** * Get the scale sample size * * @param resW resource Width * @param resh Resource Height * @param DESW result width * @param desh Result height * @return * /public static int getscaleinsamplesize (int res W, int resh, int desw, int desh) { int scalew = RESW/DESW; int Scaleh = Resh/desh; int largescale = Scaleh > Scalew? Scaleh:scalew; int samplesize = 1;
2 files in the Ucdetector_reports folderThe results of the operation are also shown in Eclipse's problem.:(iv) ScreeningTo make it easy to find the filter categories for the results in problemSelect inverted triangle → pop-up window →group By→type:(v) OptimizationFollow the prompts to find the corresponding class to deleteFor example, in the class baseactivity:Double-click the entry in the problem to enter the appropriate class:(vi) Closureplug-in use to note :Reflection , configuration injecti
=null// execution time consuming memory operation, or call time consuming memory method ... } At this point it is necessary to assign the OBJ value to null to release the reference to the object as soon as possible.
Try to cache frequently used objectsAs much as possible to cache objects that are used frequently, you can use arrays, or hashmap containers for caching, but this can cause the system to consume too much cache and degrade performance, and it is recommended to use some thir
-filter>activity>This is not finished, because we set up a SplashActivity background map, which will inevitably lead to transitions drawn, so we set the theme back to the original before it initializes:@Override protectedvoidonCreate(Bundle savedInstanceState) { setTheme(R.style.AppTheme); super.onCreate(savedInstanceState); setContentView(R.layout.splash_activity);Above.Now you will find that even if the boot time is longer, it will not appear 白屏 .Reference:
Htt
materials (instance) will cause the batch to fail. 7, objects with Lightmap contain additional (hidden) material attributes, such as lightmap offset and scaling coefficients. Therefore, objects that have lightmap will not be batched (unless they point to the same parts of Lightmap). 8, multichannel shader can interfere with batch operations. For example, almost all shaders in unity support multiple light sources in forward rendering and effectively open multiple channels for them. 9,
能回收很少的对象,一般使用的是标记整理或者标记清除算法In the above way, the whole process of GC has reached the most efficient state.It is important to note the use of replication algorithms in the generational recovery algorithm.The previously mentioned replication algorithm is to divide the memory into two, but in the generational recycling is not so, but according to Eden:survivor A:survivor b= 8:1:1, the specific process is (simplified version):1.新创建一个对象,默认是分在Eden区域,当Eden区域内存不够的时候,会触发一次Minor GC(新生代回收),这次回收将存活的对象放到Surv
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.